/**
 * 
 */
package br.com.lazyprogrammer.worldsoccermanager.system.message;

import android.content.Context;
import android.widget.Toast;

import br.com.lazyprogrammer.worldsoccermanager.R;
import br.com.lazyprogrammer.worldsoccermanager.network.Request;

/**
 * 
 * @author Limao Games <br />
 * <b>Email:</b> andreikeda@limaogames.com.br <br />
 * created on: 07/05/2014
 * @version 1.0
 * @see 
 */
public class Message {
	
	public static String getException(Context context, Request.Response status) {
		switch(status) {
			case AlreadyRegistered:
				return context.getString(R.string.exception_register_user_not_available);
				
			case ClientProtocol:
				return context.getString(R.string.exception_client_protocol);
				
			case IllegalState:
				return context.getString(R.string.exception_illegal_state);
				
			case IO:
				return context.getString(R.string.exception_io);
				
			case JSON:
				return context.getString(R.string.exception_json);
				
			case NullPointer:
				return context.getString(R.string.exception_nullpointer);
				
			case ServerError:
				return context.getString(R.string.exception_server_unavailable);
				
			case SocketTimeout:
				return context.getString(R.string.exception_socket_timeout);
				
			case TypeMismatch:
				return context.getString(R.string.exception_login_user_not_available);
				
			case UnsupportedEncoding:
				return context.getString(R.string.exception_unsupported_encoding);
				
			default:
				return context.getString(R.string.exception_unable_connect_db);
		}
	}
	
	/**
	 * 
	 * @param s
	 * @return
	 */
	public static String format(String s) {
	    s = s.replaceAll("[éèëê]","e");
	    s = s.replaceAll("[úùüû]","u");
	    s = s.replaceAll("[íìï]","i");
	    s = s.replaceAll("[áàãâä]","a");
	    s = s.replaceAll("[óòõôö]","o");

	    s = s.replaceAll("[ÉÈËÊ]","E");
	    s = s.replaceAll("[ÚÙÜÛ]","U");
	    s = s.replaceAll("[ÍÌÏ]","I");
	    s = s.replaceAll("[ÁÀÃÂÄ]","A");
	    s = s.replaceAll("[ÓÒÕÔÖ]","O");
	    return s;
	}

    /**
	 * 
	 * @param c
	 * @param message
	 */
	public static void send(Context c, String message) {
		Toast.makeText(c, message, Toast.LENGTH_LONG).show();
	}
	
	/**
	 * 
	 * @param c
	 * @param msgId
	 */
	public static void send(Context c, int msgId) {
		Toast.makeText(c, msgId, Toast.LENGTH_LONG).show();
	}

}
